package com.ruoyi.common.utils;

//import com.alipay.api.AlipayApiException;
//import com.alipay.api.AlipayClient;
//import com.alipay.api.AlipayConfig;
//import com.alipay.api.DefaultAlipayClient;
//import com.alipay.api.domain.AlipayFundTransCommonQueryModel;
//import com.alipay.api.domain.AlipayTradeRefundModel;
//import com.alipay.api.request.AlipayFundTransCommonQueryRequest;
//import com.alipay.api.request.AlipayTradeRefundRequest;
//import com.alipay.api.response.AlipayFundTransCommonQueryResponse;
//import com.alipay.api.response.AlipayTradeRefundResponse;
//import com.ruoyi.project.system.domain.SysPayOrder;
import lombok.extern.slf4j.Slf4j;
import java.math.RoundingMode;

@Slf4j
public class AlibabaApi {

//    public static AlipayFundTransCommonQueryResponse query(SysPayOrder sysPayOrder) throws AlipayApiException {
//        // 初始化SDK
//        AlipayClient alipayClient = getAlipayConfig();
//        // 构造请求参数以调用接口
//        AlipayFundTransCommonQueryRequest request = new AlipayFundTransCommonQueryRequest();
//        AlipayFundTransCommonQueryModel model = new AlipayFundTransCommonQueryModel();
//        // 设置销售产品码
//        model.setProductCode("TRANS_ACCOUNT_NO_PWD");
//        // 设置描述特定的业务场景
//        model.setBizScene("DIRECT_TRANSFER");
//        // 设置商户转账唯一订单号
//        model.setOutBizNo(sysPayOrder.getOrderNo());
//        request.setBizModel(model);
//        return alipayClient.certificateExecute(request);
//    }
//
//    public static AlipayTradeRefundResponse refund(SysPayOrder sysPayOrder) throws AlipayApiException {
////        if (1 == 1){
////            System.out.println("-------执行退款--------"+sysQueryPay);
////            return null;
////        }
//        // 初始化SDK
//        AlipayClient alipayClient = getAlipayConfig();
//        AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
//        AlipayTradeRefundModel model = new AlipayTradeRefundModel();
//        // 设置商户订单号
//        model.setOutTradeNo(sysPayOrder.getOrderNo());
//        // 设置部分退款单号
//        model.setOutRequestNo(sysPayOrder.getRemark());
//        // 设置退款金额
//        model.setRefundAmount(sysPayOrder.getActualPayAmount().setScale(2, RoundingMode.HALF_UP).toString());
//        request.setBizModel(model);
//        return alipayClient.certificateExecute(request);
//    }
//
//    private static DefaultAlipayClient getAlipayConfig() throws AlipayApiException {
//        AlipayConfig alipayConfig = new AlipayConfig();
//        //设置网关地址
//        alipayConfig.setServerUrl("https://openapi.alipay.com/gateway.do");
//        //设置应用APPID
//        alipayConfig.setAppId("2021005116605770");
//        //设置应用私钥
//        alipayConfig.setPrivateKey("MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCq6wWkBL/8W1Z7l/nc3xv8a/BVWr2hOjXFsnGtZVKzrM/+9LquGIdo+2RCrjiReUvIZ+YpvsV7hoUqKd+/t56ShRSvz0uhHzrKclGtFd3GFQPTO+XJtC4a7lZHjzNIGgfmjWmnB2sKJJzH9FsPDzhuc/tyUcjXnTnKrpeKBoDzo48bLOcmGy053SJPZTkIn/ANPkUw+avOC0StRDzuTUW/0/xQ+5u6cfcj/2sfRNbbRGE0Dz2xVmqCC+KN+wDOdyTyWNEgHKsaprdOgOUFaVCTaTt9bmfkzW/ZlP3xoKYDXjtMKwHzrS7wS6Hnj/r9jOP2+yEp3X89xGJIj0TiCywlAgMBAAECggEBAJDuATZ3oKRIfykGUaVsurpsfLqj2zCfv4EIM0SpKluZKjYzJykBO7FVmkrAmM8iX5RsJcs4LRT1mG2MXGKhPSFZH5WE3cieRqfsED4I0KlqoHe5zrwewQmtGBRN5Vo6WICzYOd1btqG+TrEhYJbkap3RrxFhVzvwVWQfodXxHjSzpqUkbU0hI7GcNa/yhKnXLyD+JmcJWZVFh2JHbNLt/uaX00OfLxFfAx8/tuPBNPmnRyGJC2xACN4abW23a+wdiLBVFucNTQkGR2vKpbVRkgAuho5Dpp+bG2f+JfMJd8ul3AKLYRue7QP24rToa0eVPlu23aMtMUwhPvP/1qXxIECgYEA7bo2BaosuZVdmGlAYYrVtRBm7zsyVs4uNh6Mxs6DdcW7DYZ297Mr4CoOdlxFmnPOHU+d1x7fQOLmYr9HlgXnIX8XvewmHec963b4zQyAqczNihAhWreiGM8ctcgFNbXgJex8pZPwvaU4SUAZkl+IuSZJhCfkvUfvHYggZChBEc0CgYEAuA4yNoOye88MuYH5bM8QFpiGFodTlL5wFIi2j+HxOujItWnYH4diIiurb428U8+TFGSHgmDpO59KliFu8mQcC/w9VqiCJbc6FES53MuiqY1l+FGXYV6Q7jZJTWpH7ADRSSPl33LKBbUV5BgIu0Z4wsL3gEY0VXS/yqfnIiDHi7kCgYEAk0wAswvZQHgzEP+OG6IpflIWZX65Vx3TdkcBlSFaRPvqRZweVKYYtoF4io/rtKKygGjXdPY1AIBWnbLFSUiJCLE15cDPcVHZhO8ng+2OPyed50DNWedUMakKsfuodrolk3nvVazPysH3mTN1ZMN69LWrcY5CZaGPoC27XDOw9bUCgYASydAyZGs53D7uSOhPRSvdQqCdeB7+FhqW3gXU1jmry8uBSVa4kTdhSZfsgUlyPMRE1qZGluH4JiCVBsCuma2LQ6p3SChQ9U1GeGWItnjaWgbIvHt5gw/EYWJGNs00uDilALccgjlBL+UWLaXmiCEXsJNXUtNQzeQuKcmcYEA+cQKBgFOiTNysrbHgJjg3P0hlLlwTrww3eO8sYfo+x1wbnaZu8LHgQ18a+1dxOjgvJk/80sNvIsHTVKwB64NB+1MVpzwZyxKsnFhl25wF/DfW3e/Kj9tvssmf1SWRb6KWJ9e/JjVm2NWbBoNGSym0Zn3OsP0v4AM0UKF0hN7YKFcxbSOB");
//        //设置应用公钥证书路径
//        alipayConfig.setAppCertPath("/foo/appCertPublicKey_2021005116605770.crt");
//        //设置支付宝公钥证书路径
//        alipayConfig.setAlipayPublicCertPath("/foo/alipayCertPublicKey_RSA2.crt");
//        //设置支付宝根证书路径
//        alipayConfig.setRootCertPath("/foo/alipayRootCert.crt");
//        //设置请求格式，固定值json
//        alipayConfig.setFormat("json");
//        //设置字符集
//        alipayConfig.setCharset("UTF-8");
//        //设置签名类型
//        alipayConfig.setSignType("RSA2");
//        //构造client
//        return new DefaultAlipayClient(alipayConfig);
//    }

}
